package com.itshen.mapper;

import com.itshen.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * mapper
 *
 * @author stephen.shen
 * @email shenzhaoxiang@gmail.com
 * @date 2020-02-14 12:09
 */
@Mapper
public interface UserMapper {

    @Select("SELECT * from tbl_user")
    List<User> queryAll();

    @Insert("UPSERT INTO tbl_user VALUES( #{id}, #{name}, #{age} )")
    void save(User user);

    @Select("SELECT * FROM tbl_user WHERE name = #{name} AND age = #{age}")
    User queryByNameAndAge(String name, Integer age);

    @Delete("DELETE FROM tbl_user WHERE age = #{age}")
    void deleteByAge(Integer age);
}
